<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="isShow=!isShow">点我</button>
    <child v-if="isShow"></child>
</div>
</body>
<script>
    new Vue({
        el : '#root',
        data :{
            isShow:true
        },
        components:{
            Child:{
                template:(`
                    <div>
                        <button @click="fn">销毁</button>
                    </div>

                `),
                data(){
                    return {
                        num :100
                    }
                },
                beforeDestroy(){
                    console.log('beforeDestroy')
                },
                destroyed(){
                    console.log('destroyed')
                },
                methods:{
                    fn(){
                        this.$destroy();
                    }
                }
            }
        }
    })
</script>
</html>